<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <!-- 2、求出1 -1/2 + 1/3 - 1/4 + 1/5....... 1/100的和 -->

    <!-- 根据1/奇数，-1/偶数的逻辑来运算1~100之间的数字和 -->

    <script>
        var ji=0;
        var ou=0;
        for(var num=1;num<=100;num++){
            if(num%2!==0){
                var ji=1/num +ji;
            }
            else if(num%2==0){
                var ou=-1/num +ou;
            }
            var all=ji+ou;
        }
        console.log(all);
        
    </script>

</body>
</html>